let rec reset_list l = match l with
	  []   -> ()
	| e::l -> e#reset
		
let rec eval_list l dir = match l with
	  []   -> -1
	| e::l ->
		(if (e#eval dir) then e#get_gesture
		else eval_list l dir)
		
let rec to_string_list l = match l with
	  []   -> ""
	| e::l -> (e#to_string)^"\n"^(to_string_list l)

let rec get_string_id id l = match l with
	  []   -> ""
	| e::l -> if (id = e#get_gesture) then e#to_string
				else to_string_list l
	
class t_chrSys =
object (this)
	(* Variables membres de la classe *)
	val mutable nb_automatons = 0
	val mutable automaton_list = []
	val mutable automaton_rec = new Automaton.t_automaton
	(* Methodes de la classe *)
	method reset = reset_list automaton_list
	method begin_acquire = if (not automaton_rec#is_empty) then automaton_rec <- new Automaton.t_automaton; this#reset
	method end_acquire =
		if (not automaton_rec#is_empty) then
			(nb_automatons <- nb_automatons + 1;
			 automaton_rec#set_gesture nb_automatons;
			 automaton_list <- automaton_rec::automaton_list;
			 nb_automatons)
		else -1
	method build_automaton new_dir = automaton_rec#build new_dir
	method update new_dir =
		let res = eval_list automaton_list new_dir in
			if (res <> -1) then this#reset; res
	method get_string_id id = get_string_id id automaton_list
	method to_string i = if (i = 0) then (); to_string_list automaton_list
end
